/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author corneliugosa
 */
@Entity
@Table(name = "class")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Class.findAll", query = "SELECT c FROM Class c"),
    @NamedQuery(name = "Class.findById", query = "SELECT c FROM Class c WHERE c.id = :id")
})
public class Class implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "number")
    private int number;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "series")
    private String series;
    @Basic(optional = false)
    @NotNull
    @Column(name = "year")
    private int year;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idClass")
    private List<Timetable> timetableList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idClass")
    private List<HomeworkToClass> homeworkToClassList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idClass")
    private List<Homework> homeworkList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cls")
    private List<PersonToClass> personToClassList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cls")
    private List<Exams> examsList;

    public Class() {
    }

    public Class(Integer id) {
        this.id = id;
    }

    public Class(Integer id, int number, String series, int year) {
        this.id = id;
        this.number = number;
        this.series = series;
        this.year = year;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public String getSeries() {
        return series;
    }

    public void setSeries(String series) {
        this.series = series;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    @XmlTransient
    public List<Timetable> getTimetableList() {
        return timetableList;
    }

    public void setTimetableList(List<Timetable> timetableList) {
        this.timetableList = timetableList;
    }

    @XmlTransient
    public List<HomeworkToClass> getHomeworkToClassList() {
        return homeworkToClassList;
    }

    public void setHomeworkToClassList(List<HomeworkToClass> homeworkToClassList) {
        this.homeworkToClassList = homeworkToClassList;
    }

    @XmlTransient
    public List<Homework> getHomeworkList() {
        return homeworkList;
    }

    public void setHomeworkList(List<Homework> homeworkList) {
        this.homeworkList = homeworkList;
    }
    
    @XmlTransient
    public List<PersonToClass> getPersonToClassList() {
        return personToClassList;
    }

    public void setPersonToClassList(List<PersonToClass> personToClassList) {
        this.personToClassList = personToClassList;
    }

    @XmlTransient
    public List<Exams> getExamsList() {
        return examsList;
    }

    public void setExamsList(List<Exams> examsList) {
        this.examsList = examsList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Class)) {
            return false;
        }
        Class other = (Class) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Class[ id=" + id + " ]";
    }
    
}
